package com.hottop.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hottop.common.annotation.Log;
import com.hottop.common.core.controller.BaseController;
import com.hottop.common.core.domain.AjaxResult;
import com.hottop.common.enums.BusinessType;
import com.hottop.system.domain.SysChart;
import com.hottop.system.service.ISysChartService;
import com.hottop.common.utils.poi.ExcelUtil;
import com.hottop.common.core.page.TableDataInfo;

/**
 * 图信息数据Controller
 * 
 * @author ruoyi
 * @date 2022-02-19
 */
@RestController
@RequestMapping("/system/chart")
public class SysChartController extends BaseController
{
    @Autowired
    private ISysChartService sysChartService;

    /**
     * 查询图信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:chart:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysChart sysChart)
    {
        startPage();
        List<SysChart> list = sysChartService.selectSysChartList(sysChart);
        return getDataTable(list);
    }

    /**
     * 导出图信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:chart:export')")
    @Log(title = "图信息数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysChart sysChart)
    {
        List<SysChart> list = sysChartService.selectSysChartList(sysChart);
        ExcelUtil<SysChart> util = new ExcelUtil<SysChart>(SysChart.class);
        util.exportExcel(response, list, "图信息数据数据");
    }

    /**
     * 获取图信息数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:chart:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysChartService.selectSysChartById(id));
    }

    /**
     * 新增图信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:chart:add')")
    @Log(title = "图信息数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysChart sysChart)
    {
        return toAjax(sysChartService.insertSysChart(sysChart));
    }

    /**
     * 修改图信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:chart:edit')")
    @Log(title = "图信息数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysChart sysChart)
    {
        return toAjax(sysChartService.updateSysChart(sysChart));
    }

    /**
     * 删除图信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:chart:remove')")
    @Log(title = "图信息数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysChartService.deleteSysChartByIds(ids));
    }
}
